package testsuite;

import java.io.IOException;

import lib.random.ExtendedRandom;
import formatter.CodeforcesFormatter;

/**
 * A base class for all test case generators for TopCoder MPSQAS
 *
 * Reminder: You must close TestSuite after every tests
 *
 * @author dolphinigle
 */
public abstract class CFTestSuite extends TestSuite {

  /**
   * Random number generator.
   */
  private ExtendedRandom ext_;

  /**
   * Filename where to write the cases to
   */
  private String base_path_;

  /**
   * BufferedWriter of this.getFilename();
   */
  private CodeforcesFormatter formatter_;

  /**
   * Constructs a test suite that's responsible for
   * @param filename name of file to where the result is to be written
   * @throws IOException if opening file to write failes
   */
  public CFTestSuite(String base_path) {
    this.ext_ = new ExtendedRandom(System.currentTimeMillis());
    this.base_path_ = base_path;
    this.formatter_ = new CodeforcesFormatter(base_path, 0);
  }

  /**
   * Returns the filename to where this test suit is writing
   * @return the filename
   */
  public String getBasePath() {
    return this.base_path_;
  }

  /**
   * Return the TopCoderFormatter to where this test suite writes to
   * @return the formatter
   */
  protected CodeforcesFormatter getFormatter() {
    return this.formatter_;
  }

  /**
   * Return the number random generator for this test suite.
   * @return
   */
  protected ExtendedRandom ext() {
    return this.ext_;
  }

  /**
   * Generates a number of random test cases depending on the suit and write
   * them to the stream
   * @param number_of_tests rough guide on the number of tests. Generally
   * larger means stronger tests. However this is not a strict guide.
   * Some implementations ignore this parameter, which is completely fine.
   */
  public abstract void generateRandomCases(int number_of_tests);

}
